package com.gmcc.docmanager.loader;

import java.io.InputStream;

import org.apache.http.HttpResponse;

public class LoginResponseParser extends ResponseParser {

	public LoginResponseParser(ResponseListener listener) {
		super(listener);
	}

	@Override
	public void doParse(String url, HttpResponse httpresp, InputStream is,
			String postData) {
		super.doParse(url, httpresp, is, postData);

		if (netResult && rootElement != null) {
			boolean result = false;
			result = stringToBoolean(getNodeTextValue("authResult"));
			String errorMsg = getNodeTextValue("errorMsg");
			if (!result) {
				listener.onResponse(createFailureResponse(errorMsg));
			} else {
				Response response = new Response();
				response.setCode(0);
				response.setDescription(errorMsg);
				response(response);
			}
		}
	}

}
